PATHMac OS 8 and 9 Developer Documentation > Interapplication Communication > AppleScript for Scripters >

AppleScript Language Guide

   

Styled Clipboard Text

The Styled Clipboard Text value class represents text data from the Clipboard that includes style and font information. Although you can't coerce this value class to any other class or display it in its native format, you can use it to pass styled text between applications that work with styled text.

The following script copies all of the text, consisting of the one word "Hello" in outline font, from the document "Hello with style" to the Clipboard. It then gets the contents of the clipboard and displays the class of those contents.

tell application "AppleWorks"
    set myText to text body of document "Hello with style"
    activate -- Required for Clipboard commands.
    -- Next two lines use scripting addition commands.
    set the clipboard to myText
    set myClipboardText to the clipboard as scrap styles
    --result: «data styl000100000000000F000A001008A0000C000000000000»
    class of myClipboardText --result: styled Clipboard text
end tell

As shown in the script, getting styled text from the Clipboard results in a value of type Styled Clipboard Text, which AppleScript can only display as raw data enclosed in chevrons (double-angle brackets). Although you cannot coerce styled clipboard text to styled text or to a string, you can store it in a variable and pass it to applications that work with styled text.

For more information on raw data, see Double Angle Brackets in Results and Scripts.


© 1999 Apple Computer, Inc. – (Last Updated 21 May 99)